

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>修改客户信息</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui-v2.5.5/layui/css/layui.css" media="all" type="text/css">
</head>
<body>
	<form method="post" id="form1">
  <label><font size="4" style="font-weight:bold;">|基本资料</font></label>
 	
 	<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label"><font color="red">*</font>客户:</label>
      <div class="layui-input-inline">
        <input type="text" id="cname1" name="cname" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">手机号码:</label>
      <div class="layui-input-inline">
        <input type="text" id="cphone1" name="cphone" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">客户类型</label>
      <div class="layui-input-inline">
      	<select name="label" id="type_id1"  lay-verify="type_id">>
          <option value="0">请选择类型</option>
        </select>
      </div>
      <label class="layui-form-label"><font color="red">*</font>证件号:</label>
      <div class="layui-input-inline">
        <input type="text" id="idnumber1" name="idnumber" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
    </div>
   
  </div>
  
  <!-----------------------分割---------------------------->
  <label>
  	<font style="font-weight: bold;" size="4">|其他选填&nbsp;&nbsp;&nbsp;</font>
  </label>
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
  	<div class="layui-form-item">
  		<label class="layui-form-label">主要负责人:</label>
      <div class="layui-input-inline">
        <input type="text" id="principal1" name="principal" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">业务联系人:</label>
      <div class="layui-input-inline">
        <input type="text" id="salesman1" name="salesman" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">邮箱:</label>
      <div class="layui-input-inline">
        <input type="text" id="mailbox1" name="mailbox" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">职务:</label>
      <div class="layui-input-inline">
        <input type="text" id="duty1" name="duty" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">地区影响力:</label>
      <div class="layui-input-inline">
        <input type="text" id="influence1" name="influence" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">固定电话:</label>
      <div class="layui-input-inline">
        <input type="text" id="specialplane1" name="specialplane" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">所属地区:</label>
      <div class="layui-input-inline">
        <input type="text" id="region1" name="region" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">客户状态:</label>
      <div class="layui-input-inline">
        <select id="state_id1" name="state_id" lay-verify="required">>
        	<option value="0">请选择状态</option>
        </select>
      </div>
  	</div>
  	<div class="layui-form-item">
  				<!--<el-form-item label="身份特征">
				     <el-radio-group v-model="Client_message.characteristics">
					    <el-radio label="妇女">妇女</el-radio>
					    <el-radio label="未成年人">未成年人</el-radio>
					    <el-radio label="残疾人">残疾人</el-radio>
					    
					    <el-radio label="老年人">老年人</el-radio>
					    <el-radio label="农民">农民</el-radio>
					    <el-radio label="农民工">农民工</el-radio>
					    
					    <el-radio label="下岗职工">下岗职工</el-radio>
					    <el-radio label="城市居民">城市居民</el-radio>
					    <el-radio label="外来人员">外来人员</el-radio>
					  </el-radio-group>
				  </el-form-item>-->
		</div>
  	<div class="layui-form-item">
  		<label class="layui-form-label">法定代表人:</label>
      <div class="layui-input-inline">
        <input type="text" id="legalperson1" name="legalperson" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
      <label class="layui-form-label">法人联系方式:</label>
      <div class="layui-input-inline">
        <input type="text" id="legalpersonphone1" name="legalpersonphone" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">民族:</label>
      <div class="layui-input-inline">
        <input type="text" id="nation1" name="nation" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">性别:</label>
      <div class="layui-input-inline">
        <select id="sex1" name="sex" lay-verify="required">
        	<option value="男">男</option>
        	<option value="女">女</option>
        </select>
      </div>
      <label class="layui-form-label">出生日期:</label>
      <div class="layui-input-inline">
        <input type="text" class="layui-input" id="birthdate1" name="birthdate" lay-verify="required"  autocomplete="off" class="layui-input">
      </div>
  	</div>
  	
  	<div class="layui-form-item">
  		<label class="layui-form-label">详细地址:</label>
      <div class="layui-input-inline" style="width: 55%;">
        <input type="text" id="site1" name="site" lay-verify="required"  autocomplete="off" class="layui-input" >
      </div>
  	</div>
  	<div class="layui-form-item">
      <label class="layui-form-label">备注:</label>
      <div class="layui-input-inline">
        <textarea name="remark" id="remark1" lay-verify="required" style="width: 400px; height: 20px;" autocomplete="off" class="layui-textarea"></textarea>
      </div>
    </div>
    
    <div class="layui-form-item">
    	<label class="layui-form-label"></label>
      <div class="layui-input-inline">
        <input type="button" id="submit"	class="layui-btn layui-btn-radius" lay-verify="required" lay-filter="status" name="button" value="确定提交">
      </div>
    </div>
  </div>
  </form>
  <script src="../../../layuiadmin/layui-v2.5.5/layui/layui.js" type="text/javascript"></script>
  <script src="../../../layuiadmin/jquery/jquery.min.js" type="text/javascript"></script>
  <script>
  	
   $(function(){
   	var parentd=(parent.parentData);
		   	var clientId=parentd.clientId
   	layui.use(['table','form',], function(){
					var table = layui.table,
					 form = layui.form; 
		   		$.ajax({
		    	type:"post",
		    	url:"http://localhost:8080/client/getbymessageid",
		    	async:true,
		    	data:{"clientId":clientId},
		    	success:function(obj){
						$("#cname1").val(obj.name);
						$("#cphone1").val(obj.phone);
						//选中客户类型下拉框中的选项
						var type = 'dd[lay-value='+obj.typeId.typeId+']';
						$("#type_id1").siblings("div.layui-form-select").find('dl').find(type).click();
						$("#idnumber1").val(obj.idnumber);
						$("#principal1").val(obj.principal);
						$("#salesman1").val(obj.salesman);
						$("#mailbox1").val(obj.mailbox);
						$("#duty1").val(obj.duty);
						$("#influence1").val(obj.influence);
						$("#specialplane1").val(obj.specialplane);
						$("#region1").val(obj.region);
						var state = 'dd[lay-value='+obj.stateId.stateId+']';
						$("#state_id1").siblings("div.layui-form-select").find('dl').find(state).click();
						$("#legalperson1").val(obj.legalperson);
						$("#legalpersonphone1").val(obj.legalpersonphone);
						$("#nation1").val(obj.nation);
						$("#sex1").val(obj.sex);
						$("#birthdate1").val(obj.birthdate);
						$("#site1").val(obj.site);
						$("#remark1").val(obj.remark);
		    	}
		    });
    });
   
   	//客户类型下拉框赋值
   	$.ajax({
    	type:"post",
    	url:"http://localhost:8080/client/typeall",
    	async:false,
    	success:function(date){
    		for(var i=0;i<date.length;i++){
    			var option = new Option(date[i].typeName,date[i].typeId);
					$("#type_id1").append(option);
    		}
    	}
    });
    //客户状态下拉框赋值
    $.ajax({
    	type:"post",
    	url:"http://localhost:8080/client/liststateall",
    	async:false,
    	success:function(date){
    		for(var i=0;i<date.length;i++){
    			var option = new Option(date[i].stateName,date[i].stateId);
					$("#state_id1").append(option);
    		}
    	}
    });
    
    //修改客户信息
    $("#submit").click(function(){
	$.ajax({
    		type:"post",
    		url:"http://localhost:8080/clientMessage/updatemessage",
    		async:true,
    		data:{"clientId":clientId,
    				"name":$("#cname1").val(),
						"phone":$("#cphone1").val(),
    				"typeId":$("#type_id1").val(),
						"idnumber":$("#idnumber1").val(),
						"principal":$("#principal1").val(),
						"salesman":$("#salesman1").val(),
						"mailbox":$("#mailbox1").val(),
						"duty":$("#duty1").val(),
						"influence":$("#influence1").val(),
						"specialplane":$("#specialplane1").val(),
						"region":$("#region1").val(),
						"state_id":$("#state_id1").val(),
						"legalperson":$("#legalperson1").val(),
						"legalpersonphone":$("#legalpersonphone1").val(),
						"nation":$("#nation1").val(),
						"sex":$("#sex1").val(),
						"birthdate":$("#birthdate1").val(),
						"site":$("#site1").val(),
						"remark":$("#remark1").val()},
    		success:function(obj){
    			if(obj=='alter'){
    				alert("修改成功");
    				//关闭当前最新开启的弹窗
    				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
						parent.layer.close(index); //再执行关闭 
    			}
    		}
    	});
    });
    });
  </script>
</body>
</html>